﻿namespace WebSocketDemo
{
    public class WebSocketClientCollection
    {
        private static List<WebSocketClient> _clients = new List<WebSocketClient>();

        public static void Add(WebSocketClient client)
        {
            _clients.Add(client);
        }

        public static void Remove(WebSocketClient client)
        {
            _clients.Remove(client);
        }

        public static WebSocketClient Get(string clientId)
        {
            var client = _clients.FirstOrDefault(c => c.Id == clientId);

            return client;
        }

        public static List<WebSocketClient> GetAll()
        {
            return _clients;
        }

        public static List<WebSocketClient> GetClientsByRoomNo(string roomNo)
        {
            var client = _clients.Where(c => c.RoomNo == roomNo);
            return client.ToList();
        }
    }
}
